﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Interactivity;

namespace Behaviors
{
    public class DragTargetBehavior : Behavior<UIElement>
    {
        public delegate bool DropObjectOKCallback(object sender, DragDropDataEventArgs args);
        public event DropObjectOKCallback DropObjectOK;
        internal bool DropOK(UIElement dropObject)
        {
            if (DropObjectOK == null)
            {
                return false;
            }
            return DropObjectOK(this, new DragDropDataEventArgs() { sourceElement = dropObject});
        }

        /// <summary>
        /// Fired when we woul dlike to see the object dropped - and you've already said "OK".
        /// </summary>
        public event Action<UIElement, UIElement> DropObject;

        internal void OnDropObject(UIElement dropObj)
        {
            if (DropObject != null)
            {
                DropObject(dropObj, AssociatedObject);
            }
        }
    }
}
